package com.cmwa.scbp.base.config.web;

import javax.annotation.Resource;
import javax.servlet.Filter;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.cmwa.scbp.base.constants.SysProp;
import com.cmwa.scbp.base.filter.GlobalFilter;

@Configuration
public class FilterConfig {

	@Resource
	private SysProp sysProp;

	@Bean
	public FilterRegistrationBean<Filter> globalFilter() {
		FilterRegistrationBean<Filter> filterRegistrationBean = new FilterRegistrationBean<Filter>();
		GlobalFilter globalFilter = new GlobalFilter();
		globalFilter.setSysProp(sysProp);
		filterRegistrationBean.setFilter(globalFilter);
		filterRegistrationBean.setName("globalFilter");
		filterRegistrationBean.addUrlPatterns("*.do");
		filterRegistrationBean.setOrder(1);
		filterRegistrationBean.setEnabled(true);
		return filterRegistrationBean;
	}

}
